package com.FTP;

public class util {

	/**
	 * 
	 * @param start  starting point 
	 * @param end 	 end point
	 * @return miles
	 */
	static double distance(Location start, Location end) {  
		double lat1 = start.latitude;
		double lon1 = start.longitude;
		double lat2 = end.latitude;
		double lon2 = end .longitude;
	    double theta = lon1 - lon2;  
	    double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2))  
	                + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2))  
	                * Math.cos(deg2rad(theta));  
	    dist = Math.acos(dist);  
	    dist = rad2deg(dist);  
	    double miles = dist * 60 * 1.1515;  
	    return miles;  
	}  

	static double deg2rad(double degree) {  
	    return degree / 180 * Math.PI;  
	}  
	
	static double rad2deg(double radian) {  
	    return radian * 180 / Math.PI;  
	} 
}
